﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class user_delete : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string name = Request["name"];
            CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
            try
            {
                CMSModel.User user = dal.User.First(x => x.LoginName.Contains(name));
                dal.DeleteObject(user);
                ClientScript.RegisterStartupScript(GetType(), "delete", "alert('删除成功！'),document.location='Default.aspx'", true);
                dal.SaveChanges();
            }
            catch (Exception ex)
            {
                LogYuMin.LogWriter.GetWriter(LogYuMin.LogFile.error).Write(GetType(), "deleteUser", LogYuMin.LogStates.ERROR, ex);
                ClientScript.RegisterStartupScript(GetType(), "delete", "alert('删除失败！')", true);
            }
        }
    }
}